import {defineStore} from "pinia";
import {reqHospitalDetail,reqHospitalDepartment} from '@/api/hospital/index.ts'
import {HospitalDetail,DepartmentResponseData} from '@/api/hospital/type.ts'
import {DetailState} from './interface/index'
const userDetailStore = defineStore('Detail',{
    state:():DetailState=>{
        return {
            hospitalInfo:({} as HospitalDetail),
            departmentArr:[]
        }
    },
    actions:{
        async getHospital(hoscode:string){
           let result:HospitalDetail = await reqHospitalDetail(hoscode)
            if(result.code===200){
                this.hospitalInfo=result.data
            }
        },
        async getDepartment(hoscode:string){
            let result:DepartmentResponseData= await reqHospitalDepartment(hoscode)
            if(result.code===200){
                this.departmentArr=result.data
            }
            // console.log(result)
        }
    },
    getters:{
    }
})
export default userDetailStore;